password = input("请输入密码：")

container = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'

# 1. 密码必须是数字、字母(大小写都可以)、和下划线，否则不合法
for ele in password:
    if ele not in container:
        print("密码不合法，包含非法字符", ele)
        break
# 2. 如果密码合法,就输出"密码合法"
else:
    print("密码合法", password)
